package Statistics;
import java.lang.Math;

/**
 * Single class to hold all the calculating.
 * @author Hetalar
 * 07/02/2012
 */
public class Coefficients
{
	private static final int PRIMARY_TO_AP = 1;
	private static final int AP_TO_DMG = 1;
	private static final int STR_TO_ARMOR = 1;
	private static final int DEX_TO_AtkSpd = 1;
	private static final int WIL_TO_MP = 1;
	private static final int CON_TO_HP = 1;
	private static final int ARMOR_TO_REDUCTION = 1;
	private static final int CRIT_TO_CRITRATE = 1;
	private static final int EXP_REQ_MODIFIER = 1;
	
	/**
	 * Calculates how much 1 primary stat is worth for AP.
	 * @param value Change in primary stat.
	 * @param stats Statistics object to pull level from
	 * @return calculated damage.
	 * @author Phil
	 * 09/02/2012
	 */
	public static double calcPrimStatChange(double value, Statistics stats)
	{
		double charLevel = stats.getStatValue(Statistics.STAT_LEVEL);
		
		/* --TWEAKABLES--
		 * decayRate
		 * This will justify both the intensity of the curve. 
		 * Higher the number, the more linear the degradation of main stat's effect on level.
		 * 
		 * intensityMultiplier
		 * Determines final value of end amts to be passed to result.
		 * Serves purpose as general number specifier - may be removed
		 * upon release (once numbers have been officially ironed out.
		 */
		
		int decayRate = 20;
		int intensityMultiplier = 10;
		
		double result = intensityMultiplier * ((Math.sqrt(charLevel+decayRate))/(charLevel+decayRate));
		
		//Take determined number of prime stat -> ap, multiply it by change.
		result *= value;
		
		return result * PRIMARY_TO_AP;
	}
	
	/**
	 * Calculates how much 1 point of AP
	 * is worth for damage
	 * @param valueChange in AP.
	 * @param stats Statistics object to pull AP from.
	 * @return dmg
	 * TODO: Figure out this algorithm. -Phil
	 */
	public static double calcAPChange(double value, Statistics stats)
	{
		double result = 0;
		
		return result * AP_TO_DMG;
	}
	
	/**
	 * Calculates how much 1 dex is worth for armor
	 * @param value to calculate
	 * @return calculated armor.
	 * TODO: Figure out this algorithm. -Phil
	 */
	public static double calcAttackSpeed(double value, Statistics stats)
	{
		return value * DEX_TO_AtkSpd;
	}
	
	/**
	 * Calculates how much 1 str is worth for armor
	 * @param value to calculate
	 * @return calculated armor.
	 * TODO: Figure out this algorithm. -Phil
	 */
	public static double calcArmorChange(double value, Statistics stats)
	{
		return value * STR_TO_ARMOR;
	}
	
	/**
	 * Calculate how much 1 con is worth for hp
	 * @param value to calculate
	 * @return calculated hp.
	 * TODO: Figure out this algorithm. -Phil
	 */
	
	public static double calcMaxHPChange(double value, Statistics stats)
	{
		return value * CON_TO_HP;
	}
	
	/**
	 * Calculate how much 1 will is worth for mp
	 * @param value to calculate
	 * @return calculated hp.
	 * TODO: Figure out this algorithm. -Phil
	 */
	public static double calcMaxMPChange(double value, Statistics stats)
	{
		return value * WIL_TO_MP;
	}
	
	/**
	 * Calculate how much 1 armor is worth for armor
	 * @param value to calculate
	 * @return calculated reduction.
	 * TODO: Figure out this algorithm. -Phil
	 */
	public static double calcDmgReducChange(double value, Statistics stats)
	{
		return value * ARMOR_TO_REDUCTION;
	}
	
	/**
	 * Calculate how much 1 crit is worth for crit
	 * @param value to calculate
	 * @return calculated reduction.
	 * TODO: Figure out this algorithm. -Phil
	 */
	public static double calcCritRateChange(double value, Statistics stats)
	{
		return value * CRIT_TO_CRITRATE;
	}
	
	/**
	 * Calculates the exp required to reach the next level
	 * @param level current level of the entity.
	 * @param stats of the entity.
	 * @return Exp required for next level.
	 * TODO: Figure out this algorithm. -Phil
	 */
	public static double calcExpReqLevel(double level, Statistics stats)
	{
		return (level * 32) * EXP_REQ_MODIFIER;
	}
}
